<?php
namespace Kxdr\Controller;
use Think\Controller;
class ContentController extends ExtendController {
		public function index(){
			
			$this->display();
		}
		public function sports_games(){
			Vendor("Page");
			$leg_id = I("leg_id");
			$GM = M("KxdrGames");
			$leg = $GM->where("`team_type`='league' AND `version`='sports'")->order("`game_category` DESC")->getField("`id`,`name`,CASE `game_category` WHEN 'football' THEN '足球' WHEN 'basketball' THEN '篮球' ELSE '其他' END AS `game_category`");
			$leg_id = $leg_id?$leg_id:168;
			
			$total = $GM->where("`fid`=".$leg_id." AND DATE_FORMAT(`start_time`,'%Y%m%d') > '".date("Ymd")."'")->getField("count(`id`)");
			$PAGE = new \Page($total,10);
			$page = $PAGE->show();
			
			$games = $GM->where("`fid`=".$leg_id." AND DATE_FORMAT(`start_time`,'%Y%m%d') > '".date("Ymd")."'")->order("`id` DESC")->limit($PAGE->firstRow.','.$PAGE->listRows)->getField("`match_id`,`name`,`start_time`,`pic_url`,`live_url`,`news_url`,`video_url`,`tv`,CASE `status` WHEN '3' THEN '已结束' WHEN '0' THEN '未进行' ELSE '进行中' END AS `status`");
			
			$this->assign("page",$page);
			$this->assign("leg_id",$leg_id);
			$this->assign("leg",$leg);
			$this->assign("games",$games);
			$this->display();
		}
}